# petbuild
# Builds from https://github.com/puppylinux-woof-CE/petbuilds

. ../func
. ../build.conf

URL=https://qa.debian.org/watch/sf.php/mirdir
PKG=mirdir
PKGVER=2.1-Unix
VER=2.1
COMP=tar.gz
DESC="lightweight backup utility"
DEPS=
CAT=BuildingBlock
DESKTOP=
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)	
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
#[ -f "$DESKTOP" ] || DESKTOP=not
#[ -z "$DEPS" ] && DEPS=

ARCH=$(uname -m)
case $ARCH in
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

### SPECIAL
build() {
	cd ${PKG}*
	#pwd
	./configure --prefix=/usr --bindir=/usr/bin --exec_prefix=/usr
	make || exit
	#[ ! -x bin/mirdir ] && exit
	install -d -m 0755 ${CWD}/${PKG}-${VER}-${ARCH}_${BUILD}/usr/bin
	install -s -m 0755 bin/${PKG} ${CWD}/${PKG}-${VER}-${ARCH}_${BUILD}/usr/bin/
	cd -
}
	
package() {
	# add this recipe
	install -d -m 0755 ./${PKG}_DEV-${VER}-${ARCH}_${BUILD}/usr/src/dev
	cat ${PKG}.petbuild > ./${PKG}_DEV-${VER}-${ARCH}_${BUILD}/usr/src/dev/${PKG}-build-recipe
	for p in $(ls|grep "\-${ARCH}"|grep -v "files$") ; do
		case $p in
			*_DEV*) DESC="$PKG development"; DEPS=+${PKG} ;;
			*_DOC*) DESC="$PKG documentation"; DEPS=+${PKG} ;;
			*_NLS*) DESC="$PKG locales"; DEPS=+${PKG} ;;
		esac	
		echo "packaging $p"	
		dir2pet -x -s -w="$DESC" -d="$DEPS" -c="$CAT" -p=${p} 2>&1 >/dev/null
		rm -r $p
		mv ${p}.pet ../0pets_out
	done
	#rm -r ${PKG}-install
	rm -r ${PKG}-*
	#mv -f *.files ../0logs
	echo "done!"
}

# main
retrieve ${PKG}-${PKGVER}.${COMP}
extract ${PKG}-${PKGVER}.${COMP}
build
package	
